<?php

$mcrp = './../';
include_once($mcrp . 'functions/session.php');

if($mcuser->isadmin == 0) 
{
	header('Location: ./../');
	exit;
}

$data = file_get_contents('try.dat');
$data = explode(' ', $data);

$pagecount = $data[0];
$p = $pagecount;
if(isset($_GET['p'])) $p = $_GET['p'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>µContest - try.log</title>
	<style type="text/css">
		a
		{
			text-decoration: none;
			color: #A71212;
		}

		a:hover
		{
			color: #501212;
		}

		#table
		{
			border-collapse: collapse;
			width: 98%;
			margin: auto;
			clear: both;
		}
		#table th
		{
			background-color: #EEEEEE;
			border: 1px solid black;
		}
		#table td
		{
			border: 1px solid black;
			vertical-align: top;
			padding: 2px;
		}
		.success
		{
			background-color: #B1FFAB;
		}
		.failed
		{
		
		}
		.timeout
		{
			background-color: #FAB8B8;
		}
		.hiddenbf
		{
			display: none;
		}
		.bruteforce
		{
			color: #AAAAAA;
		}
		.bruteforce a
		{
			color: #888888;
		}
		.bruteforce a:hover
		{
			color: #501212;
		}
	</style>
	<script type="text/javascript">
		function ToggleDisplay(e)
		{
			var pre = e.parentNode.getElementsByTagName('pre');
			if(pre[0].style.display == 'none')
				pre[0].style.display = 'block';
			else
				pre[0].style.display = 'none';
		}
		/*
	Developed by Robert Nyman, http://www.robertnyman.com
	Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/	
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};
function DisplayBruteforce(e)
{
	var trs = getElementsByClassName('bruteforce');
	for(var i=0, il=trs.length; i<il; i+=1)
	{
		current = trs[i];
		if(e.checked == true)
			current.className = 'bruteforce';
		else
			current.className = 'bruteforce hiddenbf';
	}
}
	</script>
</head>
<body onload="DisplayBruteforce(document.getElementById('display_bruteforce'));">
	<div>
		<span style="float:left;margin:2px 20px;"><a href="http://www.microcontest.com">Accueil</a> - <a href="javascript:history.back()">Retour</a></span>
		<span style="float:right;margin:2px 20px;"><?php for($i = $pagecount-20; $i<=$pagecount; $i++) echo '<a href="?p=' . $i . '">' . $i . ' </a>'; ?></span>
		<center><input type="checkbox" checked id="display_bruteforce" onclick="DisplayBruteforce(this);">Afficher les bruteforces</center>
		<table id="table">
			<tr>
				<th>Date</th>
				<th>IP</th>
				<th>Pseudo</th>
				<th>Epreuve</th>
				<th>Durée</th>
				<th>User</th>
				<th>Post</th>
				<th>Vars</th>
				<th>Session</th>
			</tr>
			<?php echo file_get_contents('try.log.' . $p); ?>
		</table>
		<span style="float:right;margin:2px 20px;">
			<?php
			for($i = $pagecount-20; $i<=$pagecount; $i++)
				echo '<a href="?p=' . $i . '">' . $i . ' </a>';
			?>
		</span>
	</div>
</body>
</html>